import React, { Component } from "react";

export default class Adduser extends Component {
    constructor (props) {
        super(props);
        this.state = {
            username: "",
            userage: "",
        };
    }
    add = () => {
        //alert(this.state.username+"和"+this.state.userage);
        this.props.addListItem({
            username: this.state.username,
            userage: this.state.userage
        })
    }
    render() {
        return (
            <div>
                <div>
                    用户名 <input value={this.state.username} onChange={(e) => {
                        this.setState({
                            username: e.target.value
                        })
                    }} />{" "}
                </div>
                <div>
                    年龄 <input value={this.state.userage} onChange={(e) => {
                        this.setState({
                            userage: e.target.value
                        })
                    }} />{" "}
                </div>
                <button onClick={() => {
                    this.add();
                }}>新增</button>
            </div>
        );
    }
}